package com.conception.designpattern.strategy;

public class EncryptLogger {
	
	private EncryptionStrategy currEncryptionStrategy;
	

	private FileLogger logger;
	
	public EncryptLogger(FileLogger inp_logger){
		logger = inp_logger;
		//set the default encryption strategy
		setCurrEncryptionStrategy(new SimpleEncryption());
		
	}
	
	public void log(String fileName,String msg){
		/* added functionality */
		msg = encrypt(msg);
		/* now forward the encrypted text to the fileLogger for storage */
		logger.log(fileName,msg);
	}
	
	public String encrypt(String msg){
		/* Apply encryption using the current encryption strategy */
		return currEncryptionStrategy.encrypt(msg);
	}
	
	public void setCurrEncryptionStrategy(EncryptionStrategy currEncryptionStrategy) {
		this.currEncryptionStrategy = currEncryptionStrategy;
	}
}
